package com.twang.stock.task.old;

import com.alibaba.fastjson.JSONObject;
import com.twang.stock.common.CommonUtils;
import com.twang.stock.email.SendmailService;
import com.twang.stock.service.jinyan.UpdtePriceAndVolService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * 更新今日数据：以及 May5、May10
 * 每日14点50更新
 */
@Slf4j
@Service
public class UpdateMay5AndMay10 extends BaseTask{

    @Autowired
    private UpdtePriceAndVolService updtePriceAndVolService;

    @Autowired
    private SendmailService sendmailService;


   // @Scheduled(cron = "0 10 15 * * ?")
    public void updateMay5AndMay10() {
        try{
            if (!isWork()) {
                return;
            }
            updtePriceAndVolService.updtePriceAndVol();
            sendmailService.insertEvent(CommonUtils.TASK_NAME_RULE_2,CommonUtils.SUCCESS_MESSAGE,"SUCCESS",CommonUtils.RULE_SUCCESS);
        }catch (Exception e){
            sendmailService.insertEvent(CommonUtils.TASK_NAME_RULE_2,CommonUtils.FAILE_MESSAGE+ JSONObject.toJSONString(e),"ERROR",CommonUtils.RULE_EXCEPTION);
        }

    }
}
